package cn.zzuli.manager.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.zzuli.manager.entity.ItemUserEntity;
import cn.zzuli.manager.service.ItemUserService;
import cn.zzuli.common.utils.PageUtils;
import cn.zzuli.common.utils.R;


/**
 * 栏目与用户之间的关系表
 *
 * @author Huanghuan
 * @email 17719158821@163.com
 * @date 2020-11-20 00:42:30
 */
@RestController
@RequestMapping("manager/itemuser")
public class ItemUserController {
    @Autowired
    private ItemUserService itemUserService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = itemUserService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{itemUserId}")
    public R info(@PathVariable("itemUserId") Integer itemUserId) {
        ItemUserEntity itemUser = itemUserService.getById(itemUserId);

        return R.ok().put("itemUser", itemUser);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ItemUserEntity itemUser) {
        itemUserService.save(itemUser);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ItemUserEntity itemUser) {
        itemUserService.updateById(itemUser);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] itemUserIds) {
        itemUserService.removeByIds(Arrays.asList(itemUserIds));

        return R.ok();
    }

}
